/*
 * Telegram.java
 *
 * Created on March 27, 2007, 2:34 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ai9hells.pgaibe.common.messaging;

/**
 *
 * @author andre.bandarra
 */
public class Telegram implements Comparable{
    private int sender;
    private int receiver;
    private int msg;
    private long dispatchTime;
    private Object extraInfo;

    /** Creates a new instance of Telegram */
    public Telegram(int sender, int receiver, int msg, long dispatchTime,
            Object extraInfo) {
        this.sender = sender;
        this.receiver = receiver;
        this.msg = msg;
        this.dispatchTime = dispatchTime;
        this.extraInfo = extraInfo;
    }

    public int getSender() {
        return sender;
    }

    public int getReceiver() {
        return receiver;
    }

    public int getMsg() {
        return msg;
    }

    public long getDispatchTime() {
        return dispatchTime;
    }
    public void setDispatchTime(long dispatchTime){
        this.dispatchTime = dispatchTime;
    }

    public Object getExtraInfo() {
        return extraInfo;
    }

    public int compareTo(Object o) {
        if (o instanceof Telegram){
            Telegram t = (Telegram)o;
            if (t.getDispatchTime() > dispatchTime){
                return -1;
            }
            if (t.getDispatchTime() < dispatchTime){
                return 1;
            }
            return 0;
        }
        throw new IllegalArgumentException("Objeto nao eh Telegram");
    }

    
}
